package day04;

public class TestArray3{
	static void add(int[] a, int x){
		for(int i=0; i<a.length; i++){
			if(a[i]==0){
				a[i] = x;
				break;
			}
		}
	}
	static void insert(int[] a, int index, int x){
		for(int i=a.length-1; i>index; i--){
			a[i] = a[i-1];
		}
		a[index] = x;
	}
	static void delete(int[] a, int index){
		for(int i=index; i<a.length-1; i++){
			a[i] = a[i+1];
		}	
	}
	
	public static void main(String[]args){
		int[] a = {1,2,3,4,5};
		int[] b = new int[a.length*2];
		for(int i=0; i<a.length; i++){
			b[i] = a[i];
		}
		a = b;
		add(a, 6);
		insert(a, 4, 10);
		delete(a, 2);
		for(int i=0; i<a.length; i++){
			System.out.print(a[i]+" ");
		}
		
	}
}